/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.yunhoo.sys.util.common;

import com.yunhoo.sys.db.util.IbatisTemplate;





/**
 *
 * @author Administrator
 */
public class StringTool {
    public static int setDeptGrade(String rule,String deptCode){
        int grade = 0;
        int deptCodeLen = deptCode.length();//部门代码长度
        String[] codeGrade = rule.split("-");

        int codeLength = 0;
        for(int i = 0;i <codeGrade.length;i++){
            codeLength += Integer.parseInt(codeGrade[i]);
            if(deptCodeLen == codeLength)
            {
                grade = i + 1;
                return grade;
            }
        }
        return grade;
    }

    public static void main(String[] args){

        String rule = (String)IbatisTemplate.query("getDeptGradeLevel", null);
        String deptcode="301";
        int grade =setDeptGrade(rule,deptcode);
        System.out.println("grade:"+grade);
    }
}
